<?php
    session_start();
    include("includes/connect.php");
    include("functions/registration_functions.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="application/json">
<title>Star Map Mobile</title>
</head>
</html>
<?php
	
    $username 	= $_GET['username'];
    $long 		= $_GET['longitude'];
    $lat 		= $_GET['latitude'];

		$userCheck = mysql_query("SELECT * FROM `user_table` WHERE `username` = '$username'"); 
		$userCheck2 = mysql_fetch_array($userCheck);
		
		if($userCheck2)
		{
			$query = mysql_query("UPDATE `user_table` SET `gps_longitude` = '$long', `gps_latitude` = '$lat' WHERE `username` = '$username'") or die("Cannot connect to database or users table");

    		if($query)
    		{   
				$error = 0;
        		echo json_encode("SUCCESS");
			}
    		else 
			{
				$error = 1;
				echo json_encode("FAILURE");
			}
		}
		else
		{
			$error = 0;
			echo json_encode("NULL USER");
		}
?>